const fs = require('fs')

const path = require('path')

function ReadFile(name) {
    return new Promise(function(resolve, reject) {
        fs.readFile(path.join(__dirname, `./files/${name}`),'utf8', (err, data) => {
            if (err) return reject('错误了')
            resolve(data)
        })
    }) 
}

ReadFile('1.txt').then((res) => {
    console.log(res);
    return ReadFile('2.txt')
})
.then((res) => {
    console.log(res);
    return ReadFile('3.txt')
})
.then((res) => {
    console.log(res);
})
.catch(err => {
    console.log(err);
    
})